package com.foreveross.law.wps.service;

import org.springframework.oxm.jaxb.Jaxb2Marshaller;

import com.foreveross.law.wps.client.GetFileListDataByType;
import com.foreveross.law.wps.client.GetFileListDataByTypeResponse;
import com.foreveross.law.wps.client.GetNewProcessRouteInfo;
import com.foreveross.law.wps.client.GetNewProcessRouteInfoResponse;
import com.foreveross.law.wps.client.GetProcessContenMemory;
import com.foreveross.law.wps.client.GetProcessContenMemoryResponse;
import com.foreveross.law.wps.client.GetProcessRouteInfo;
import com.foreveross.law.wps.client.GetProcessRouteInfoResponse;
import com.foreveross.law.wps.client.GetProcessTrackTree;
import com.foreveross.law.wps.client.GetProcessTrackTreeResponse;
import com.foreveross.law.wps.client.NewProcessSubmit;
import com.foreveross.law.wps.client.NewProcessSubmitResponse;
import com.foreveross.law.wps.client.SubmitWorkqueue;
import com.foreveross.law.wps.client.SubmitWorkqueueResponse;

/**
 * 
 * @author CZM
 *
 */
public class LawWpsServiceImpl extends BaseWpsService{
	private final static String PKG="com.foreveross.law.wps.client";
    private final static String SOAPACTIONPREFIX="http://tempuri.org/";
    private static LawWpsServiceImpl workflowClient=null;
    private LawWpsServiceImpl(){
    }
    /**
     * 获取WorkFlowWebservice客户端
     * @return
     */
    public static LawWpsServiceImpl getInstance(){
    	if(workflowClient==null){
    		workflowClient=new LawWpsServiceImpl();
    		Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	        marshaller.setContextPath(PKG);
	        workflowClient.setDefaultUri("http://wf-test.infinitus-int.com:7000/MobileInferFace/EIAC_OA_WFService.asmx");
	        workflowClient.setMarshaller(marshaller);
	        workflowClient.setUnmarshaller(marshaller);
    	}
    	return workflowClient;
    }
    
    
    /**
     * 获取新建流程路由信息
     * @return
     */
    
    public GetNewProcessRouteInfoResponse  getNewProcessRouteInfo(GetNewProcessRouteInfo info){
    	String actionName="GetNewProcessRouteInfo";
    	GetNewProcessRouteInfoResponse  resp=(GetNewProcessRouteInfoResponse )this.sendReq(info, SOAPACTIONPREFIX+actionName);
    	System.out.println(resp.getGetNewProcessRouteInfoResult());
    	return resp;
    }
    /**
     * 新建提交
     * @param info
     */
    public NewProcessSubmitResponse createProcess(NewProcessSubmit info){
    	String actionName="NewProcessSubmit";
    	NewProcessSubmitResponse  resp=(NewProcessSubmitResponse )this.sendReq(info, SOAPACTIONPREFIX+actionName);
    	System.out.println(resp.getNewProcessSubmitResult());
    	return resp;
    }
    
    /**
	    * 获取待办表单详细信息
	    * @param req
	    * @return
	    */
	    public GetProcessContenMemoryResponse getProcessContenMemory(GetProcessContenMemory req){
	    	String actionName="GetProcessContenMemory";
	    	GetProcessContenMemoryResponse resp=(GetProcessContenMemoryResponse)this.sendReq(req, SOAPACTIONPREFIX+actionName);
	    	System.out.println(resp.getGetProcessContenMemoryResult());
	    	return resp;
	    }
	    
	    /**
	     * 获取流程路由信息
	     * @param info
	     * @return
	     */
	    public GetProcessRouteInfoResponse getProcessRouteInfo(GetProcessRouteInfo info){
	    	String actionName="GetProcessRouteInfo";
	    	GetProcessRouteInfoResponse resp=(GetProcessRouteInfoResponse)this.sendReq(info, SOAPACTIONPREFIX+actionName);
	    	System.out.println(resp.getGetProcessRouteInfoResult());
	    	return resp;
	    }
	    
	    /**
	     * 流程提交
	     * @param info
	     * @return
	     */
	    public SubmitWorkqueueResponse submitWorkqueue(SubmitWorkqueue info){
	    	String actionName="SubmitWorkqueue";
	    	SubmitWorkqueueResponse resp=(SubmitWorkqueueResponse)this.sendReq(info, SOAPACTIONPREFIX+actionName);
	    	System.out.println(resp.getSubmitWorkqueueResult());
	    	return resp;
	    }
	  /**
	   * 获取流程跟踪信息
	   * @param info
	   * @return
	   */
	  public GetProcessTrackTreeResponse getProcessTrackTree(GetProcessTrackTree info){
		  String actionName="GetProcessTrackTree";
		  GetProcessTrackTreeResponse resp=(GetProcessTrackTreeResponse)this.sendReq(info, SOAPACTIONPREFIX+actionName);
	    	System.out.println(resp.getGetProcessTrackTreeResult());
	    	return resp;
	  }
	  
	  /**
	     * 2.1.2草稿、待办、待阅分类查询
	     * @return
	     */
	    public GetFileListDataByTypeResponse getFileListDataByType(GetFileListDataByType req){
	    	String actionName="GetFileListDataByType";
	    	GetFileListDataByTypeResponse   resp=(GetFileListDataByTypeResponse )this.sendReq(req, SOAPACTIONPREFIX+actionName);
			System.out.println(resp.getGetFileListDataByTypeResult());
			return resp;
	    }
}
